<html>
	<head>
		<%= stylesheet_link_tag "style" %>
	</head>

	<body id="login-page">
		<div id = "loginForm" >
			<%if session[:language] == "vi"%>
				<%= form_for @book ,{:html =>  {:multipart => true}}  do |f| %>
				<% if @book.errors.any? %>
			<div id="error_explanation">
				<h2><%= pluralize(@book.errors.count, "error") %> prohibited this book from being saved:</h2>

				<ul>
					<% @book.errors.full_messages.each do |msg| %>
					<li>
						<%= msg %>
					</li>
					<% end %>
				</ul>

			</div>
			<% end %>

			<div class="form_row">
				<strong class="contact"><%= f.label t("title") %></strong>
				<%= f.text_field :title , :html => {:class => "contact_input"}%>
				<span id="spanFN" style="color: red"></span>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("author") %></strong>
				<%= f.text_field :author , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("version") %></strong>
				<%= f.text_field :version , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("publisher") %></strong>
				<%= f.text_field :publisher , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("year") %></strong>
				<%= f.text_field :year , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("barcode") %></strong>
				<%= f.text_field :barcode , :html => {:class => "contact_input"}%>
			</div>

			<div class="form_row">
				<strong class="contact"><%= f.label t("quantity") %></strong>
				<%= f.text_field :quantity , :html => {:class => "contact_input"}%>
			</div>
			
			<div class="form_row">
				<strong class="contact"><%= f.label t("categories") %></strong>
				<select name="book[category]" id="book_category" class="contact_input">
					<option value="Arts"><%= t :arts%></option>
					<option value="Business"><%= t :business%></option>
					<option value="Comic"><%= t :comic%></option>
					<option value="Computer"><%= t :computer%></option>
					<option value="Health"><%= t :health%></option>
					<option value="Novel"><%= t :novel%></option>
					<option value="History"><%= t :history%></option>
					<option value="Technology"><%= t :technology%></option>
					<option value="Sport"><%= t :sport%></option>
					<option value="Travel"><%= t :travel%></option>
					<option value="Other" ><%= t :other%></option>
					<option value="-1" selected><%= t :choose%></option>

				</select>
			</div>

			<div class="form_row">
				<strong class="contact"><%= f.label :image %></strong>
				<%= f.file_field :image %>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("description") %></strong>
				<%= f.text_field :description , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<input type="submit" class="register" value="<%= t :submit %>" />
			</div>
			<% end %>
			<%else%>
				<%= form_for @book ,{:html =>  {:multipart => true}}  do |f| %>
				<% if @book.errors.any? %>
			<div id="error_explanation">
				<h2><%= pluralize(@book.errors.count, "error") %> prohibited this book from being saved:</h2>

				<ul>
					<% @book.errors.full_messages.each do |msg| %>
					<li>
						<%= msg %>
					</li>
					<% end %>
				</ul>

			</div>
			<% end %>

			<div class="form_row">
				<strong class="contact"><%= f.label t("title") %></strong>
				<%= f.text_field :title , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("author") %></strong>
				<%= f.text_field :author , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("version") %></strong>
				<%= f.text_field :version , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("publisher") %></strong>
				<%= f.text_field :publisher , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("year") %></strong>
				<%= f.text_field :year , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("barcode") %></strong>
				<%= f.text_field :barcode , :html => {:class => "contact_input"}%>
			</div>

			<div class="form_row">
				<strong class="contact"><%= f.label t("quantity") %></strong>
				<%= f.text_field :quantity , :html => {:class => "contact_input"}%>
			</div>
			
			<div class="form_row">
				<strong class="contact"><%= f.label t("categories") %></strong>
				<select name="book[category]" id="book_category" class="contact_input">
					<option value="Arts"><%= t :arts%></option>
					<option value="Business"><%= t :business%></option>
					<option value="Comic"><%= t :comic%></option>
					<option value="Computer"><%= t :computer%></option>
					<option value="Health"><%= t :health%></option>
					<option value="Novel"><%= t :novel%></option>
					<option value="History"><%= t :history%></option>
					<option value="Technology"><%= t :technology%></option>
					<option value="Sport"><%= t :sport%></option>
					<option value="Travel"><%= t :travel%></option>
					<option value="Other" ><%= t :other%></option>
					<option value="-1" selected><%= t :choose%></option>

				</select>
			</div>

			<div class="form_row">
				<strong class="contact"><%= f.label :image %></strong>
				<%= f.file_field :image %>
			</div>
			<div class="form_row">
				<strong class="contact"><%= f.label t("description") %></strong>
				<%= f.text_field :description , :html => {:class => "contact_input"}%>
			</div>
			<div class="form_row">
				<input type="submit" class="register" value="<%= t :submit %>" />
			</div>
			<% end %>
			<%end%>
		</div>
		<script>
			function checkNewBookForm() {
var Title = document.getElementById("book_title").value;
var AuthorId = document.getElementById("book_author").value;
var Version = document.getElementById("book_version").value;
var Publisher = document.getElementById("book_publisher").value;
var Year = document.getElementById("book_year").value;
var Barcode = document.getElementById("book_barcode").value;
var Type = document.getElementById("book_category").value;
var BookImage = document.getElementById("book_image").value;

if (Title == "") {
alert("<%= t :title%><%= t :fillout%>
	");
	return false;
	}

	if (AuthorId == "") {
	alert("
<%= t :author%><%= t :fillout%>
	");
	return false;
	}

	if (Version == "") {
	alert("
<%= t :version%><%= t :fillout%>
	");
	return false;
	}

	if (Publisher == "") {
	alert("
<%= t :publisher%><%= t :fillout%>
	");
	return false;
	}

	if (Year.length != 4) {
	alert("
<%= t :year%><%= t :fillout%>
	");
	return false;
	}

	if (Barcode == "") {
	alert("
<%= t :barcode%><%= t :fillout%>
	");
	return false;
	}

	if (Type == "-1") {
	alert("
<%= t :pleaseChoose%><%= t :categories%>
	");
	return false;
	}

	document.getElementById('new_book').submit();
	}
		</script>
	</body>
</html>
